import request from "@/utils/request";

/**
 * 获取用户频道
 * @returns  Promise
 */
export const getChannelAPI = () => {
  return request({
    url: "/v1_0/user/channels"
  });
};

/**
 * 获取所有频道
 * @returns Promise
 */
export const getAllChannelsAPI = () => {
  return request({
    url: "/v1_0/channels"
  });
};

/**
 * 删除我的频道
 * @param {number} target 频道的id
 * @returns Promise
 */
export const deleteMyChannelAPI = (target) => {
  return request({
    url: `/v1_0/user/channels/${target}`,
    method: "DELETE"
  });
};

/**
 *添加我的频道
 * @param {number} id 频道的id
 * @param {number} seq 添加频道的位置
 * @returns Promise
 */
export const addMyChannelAPI = (id, seq) => {
  return request({
    url: "/v1_0/user/channels",
    method: "PATCH",
    data: {
      channels: [
        {
          id,
          seq
        }
      ]
    }
  });
};
